﻿#region Copyright
//————————————————————————————————————————//
//	创建人员(Creator)    ：Huangyd
//	创建日期(Date)       ：2012-07-03
//  联系方式(Email)      ：aj-ayumi@163.com; gajayumi@gmail.com; ajayumi@me.com
//  描    述(Description)：
//
//	Copyright (C) 2012 ajayumi 版权所有
//————————————————————————————————————————//
#endregion
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ajayumi.Platform.Search.Win
{
    /// <summary>
    /// SearchContainer
    /// </summary>
    [ToolboxItem(true)]
    public partial class SearchContainer : UserControl
    {
        private SearchBase m_Searcher = null;
        public SearchBase Searcher
        {
            get { return this.m_Searcher; }
            set
            {
                this.m_Searcher = value;
                this.searchPanel1.Searcher = value;
            }
        }

        /// <summary>
        /// 查询委托
        /// </summary>
        [Browsable(false)]
        public Action<string> SearchHandler;

        public SearchContainer()
        {
            InitializeComponent();
        }

        protected override void OnCreateControl()
        {
            base.OnCreateControl();
            this.Dock = DockStyle.Top;
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            string sql = this.searchPanel1.GetSql();
            if (this.SearchHandler != null)
            { this.SearchHandler(sql); }
        }

        private void rbtnCommon_CheckedChanged(object sender, EventArgs e)
        {
            this.searchPanel1.Mode = ajayumi.Platform.Search.Win.SearchPanelMode.Common;
        }

        private void rbtnExpert_CheckedChanged(object sender, EventArgs e)
        {
            this.searchPanel1.Mode = ajayumi.Platform.Search.Win.SearchPanelMode.Expert;
        }

    }
}
